const app = getApp()
Page({


    data: {

    },

    onLoad: function (options) {
        this.getCollectList()
    },
    getCollectList() {
        var that = this;
        wx.request({
            url: app.globalData.baseUrl + 'api/collect/v1/wx/getCollect',
            data: {
                cWxOpenId: app.globalData.openid
            },
            method: 'POST',
            success(res) {
                that.setData({
                    bookList: res.data.data
                })
            }
        })

    },

    toTiDetail(event) {
        console.log(event.currentTarget.dataset.id)
        let id = event.currentTarget.dataset.id
        wx.navigateTo({
            url: '/pages/home/search/detail/detail?id=' + id,
        })
    },

    toGoodDetail(event) {
        let index = event.currentTarget.dataset.index
        wx.navigateTo({
            url: '../../../pages/index/spotDetail/spotDetail?cId=' + this.data.bookList[index].cSpotid,
        })

    },
    /**
     * 删除
     * @param {*} event 
     */
    delete(event) {
        var that = this;
        debugger
        wx.request({
            url: app.globalData.baseUrl + 'api/collect/v1/wx/removeCollect',
            data: {
                cId: event.currentTarget.dataset.id
            },
            method: 'POST',
            success(res) {
                wx.showToast({
                    title: '删除成功',
                })
                that.getCollectList();
            }
        })
    }
})